deleting module without any question

Dear Users!

Thanks in advance,
vasgyuszi
vasgyuszi - Thu Mar 24 12:40:04 EDT 2011

Re: deleting module without any question
vasgyuszi - Thu Mar 24 12:42:40 EDT 2011

My question would be:
how could I delete (with dxl script) a module without receive questions about existing incoming links to the module?

Re: deleting module without any question
SystemAdmin - Fri Mar 25 04:20:40 EDT 2011

vasgyuszi - Thu Mar 24 12:42:40 EDT 2011
My question would be:
how could I delete (with dxl script) a module without receive questions about existing incoming links to the module?

Delete all of the incoming links first.

DOORS is highly protective of the source of incoming links. The warning that DOORS gives is an important one from a Requirements Engineering methodology point of view. It's saying that you should go to the source of those links and make sure that it's OK to delete them because that might be a surprise to other users.

Having said that, if you're really sure that all incoming links need to be deleted then you will need to determine which link modules contain the linkset pairs that are managing those links, then you can open those link modules and delete the linksets and the links are gone.......forever....be careful, if you get this wrong you could have an angry and rioting mob at your desk, try this out on a copy of a project first.


Paul Miller
Melbourne, Australia

Re: deleting module without any question
vasgyuszi - Fri Mar 25 07:02:40 EDT 2011

SystemAdmin - Fri Mar 25 04:20:40 EDT 2011
Delete all of the incoming links first.

DOORS is highly protective of the source of incoming links. The warning that DOORS gives is an important one from a Requirements Engineering methodology point of view. It's saying that you should go to the source of those links and make sure that it's OK to delete them because that might be a surprise to other users.

Having said that, if you're really sure that all incoming links need to be deleted then you will need to determine which link modules contain the linkset pairs that are managing those links, then you can open those link modules and delete the linksets and the links are gone.......forever....be careful, if you get this wrong you could have an angry and rioting mob at your desk, try this out on a copy of a project first.


Paul Miller
Melbourne, Australia

Dear Paul,

thanks to answer me!

I'm knowing about the importancy of the links and how much trouble could caused by deleting of it.

I my case there is a project which is in fact a copy of an another project but with reduced content. This new smaller project will be adjusted only by scripts and no engineers will be working on it. All the developing activities run on the original big project. I wrote two scripts, one to extract the wanted content from the orig. project and another one to make the links and alot of project specific cross checks. This new project will be re-created each time, from scratch, by the script. That's the reason why I could delete all the links without any fear from damaging information.

My first goal were to delete all the modules. Then I recognized DOORS warns by linked modules and suspends the script run. That's what I will avoid. The local usage of "noError / lastError" doesn't help. Is there any other solution except the exact deleting of all links by opening the modules each after each?

Best regards,
vasgyuszi

Re: deleting module without any question
SystemAdmin - Sun Mar 27 05:22:19 EDT 2011

vasgyuszi - Fri Mar 25 07:02:40 EDT 2011
Dear Paul,

thanks to answer me!

I'm knowing about the importancy of the links and how much trouble could caused by deleting of it.

I my case there is a project which is in fact a copy of an another project but with reduced content. This new smaller project will be adjusted only by scripts and no engineers will be working on it. All the developing activities run on the original big project. I wrote two scripts, one to extract the wanted content from the orig. project and another one to make the links and alot of project specific cross checks. This new project will be re-created each time, from scratch, by the script. That's the reason why I could delete all the links without any fear from damaging information.

My first goal were to delete all the modules. Then I recognized DOORS warns by linked modules and suspends the script run. That's what I will avoid. The local usage of "noError / lastError" doesn't help. Is there any other solution except the exact deleting of all links by opening the modules each after each?

Best regards,
vasgyuszi

vasgyuszi wrote: Is there any other solution except the exact deleting of all links by opening the modules each after each

As far as I know, you have to delete these incoming links first. The following script should give you an idea of what you need to do - it's context will only delete incoming links for the currently open module, you will need to extend the code to delete the module and then move onto the next module.

The code does an initial check to make sure that you have edit access to all of the source modules of incoming links - if you do not have edit access, then the script will raise a warning and display the name of the module. If this happens, the script will stop and you will need to change the access rights to the source module to make sure that you have edit rights so that you can delete the links. Once you have edit access to all of the source modules, the script will then proceed to delete all of the incoming links and save the source modules - there is no undo for this - once the links are deleted, they are gone forever.
 

Object o=current
Module m=current
int count=0
 
 
bool openSourceModules(Object o) {
    ModName_ srcModRef
        string srcModName=""
        Module modSrc=null
        bool allModsOpen = true
 
        // Open all modules that are the source of incoming links in edit mode
        for srcModRef in o<-"*" do {
                srcModName=fullName(srcModRef)
                
                modSrc=edit(srcModName, false)
                if (null modSrc) {  //provide a warning if a source cannot be opened in edit mode
                        infoBox "Cannot open for Edit module: " srcModName " \n\nThis script will halt execution."
                        allModsOpen = false
                        }
        }
        if (!allModsOpen) return false
        else return true
 
}
 
 
void deleteIncomingLinks(Object o) {
        Module modSrc=null
        string srcModName=""
        ModName_ srcModRef
        Object objSrc
        Link l
      ModuleVersion sourceModVersion = null
 
        // Delete all incoming links
        for l in o<-"*" do {
                objSrc = source l
                sourceModVersion = sourceVersion l
                srcModRef = module(sourceModVersion)
                modSrc=edit(fullName(srcModRef), false)
                count++
                delete l
                flushDeletions  
                save modSrc
        }
 
} //End of deleteIncomingLinks
 
 
//***************** MAIN ********************
 
for o in m do {
        if (!openSourceModules(o)) halt
        }
 
for o in m do {
        deleteIncomingLinks(o)
        }

 

 


Paul Miller
Melbourne, Australia

 

 

Re: deleting module without any question
vasgyuszi - Tue Mar 29 04:54:37 EDT 2011

SystemAdmin - Sun Mar 27 05:22:19 EDT 2011

vasgyuszi wrote: Is there any other solution except the exact deleting of all links by opening the modules each after each

As far as I know, you have to delete these incoming links first. The following script should give you an idea of what you need to do - it's context will only delete incoming links for the currently open module, you will need to extend the code to delete the module and then move onto the next module.

The code does an initial check to make sure that you have edit access to all of the source modules of incoming links - if you do not have edit access, then the script will raise a warning and display the name of the module. If this happens, the script will stop and you will need to change the access rights to the source module to make sure that you have edit rights so that you can delete the links. Once you have edit access to all of the source modules, the script will then proceed to delete all of the incoming links and save the source modules - there is no undo for this - once the links are deleted, they are gone forever.
 

Object o=current
Module m=current
int count=0
 
 
bool openSourceModules(Object o) {
    ModName_ srcModRef
        string srcModName=""
        Module modSrc=null
        bool allModsOpen = true
 
        // Open all modules that are the source of incoming links in edit mode
        for srcModRef in o<-"*" do {
                srcModName=fullName(srcModRef)
                
                modSrc=edit(srcModName, false)
                if (null modSrc) {  //provide a warning if a source cannot be opened in edit mode
                        infoBox "Cannot open for Edit module: " srcModName " \n\nThis script will halt execution."
                        allModsOpen = false
                        }
        }
        if (!allModsOpen) return false
        else return true
 
}
 
 
void deleteIncomingLinks(Object o) {
        Module modSrc=null
        string srcModName=""
        ModName_ srcModRef
        Object objSrc
        Link l
      ModuleVersion sourceModVersion = null
 
        // Delete all incoming links
        for l in o<-"*" do {
                objSrc = source l
                sourceModVersion = sourceVersion l
                srcModRef = module(sourceModVersion)
                modSrc=edit(fullName(srcModRef), false)
                count++
                delete l
                flushDeletions  
                save modSrc
        }
 
} //End of deleteIncomingLinks
 
 
//***************** MAIN ********************
 
for o in m do {
        if (!openSourceModules(o)) halt
        }
 
for o in m do {
        deleteIncomingLinks(o)
        }

 

 


Paul Miller
Melbourne, Australia

 

 

Dear Paul,

I really appreciated your proposed solution!
I'm using it!
After calling both of your functions I added the following source line

for m in p do close (m, false)


to prevent the modules to be left in open state. Without this addition, the previously opened modules remain in the DOORS memory as opened and they have prevented the further automatic run.
Now it works perfect, but it's very slow. I know, it is because of the hierarcy, looks like:
Top-Level <- System-Level <- High-Level <- Low-Level <- Test Cases
The arrows give the relationship between the levels.
It took for one system level module, which has links only to two high level modules, around 15 minutes to clean all the links. The module has only 231 object with inlinks.

Is there no quicker way to eliminate the modules? Such as power-delete or so something. Or delete folders regardless its content?

Thank you again for your help!

Best regards,
vasgyuszi

Re: deleting module without any question
SystemAdmin - Tue Mar 29 20:49:45 EDT 2011

vasgyuszi - Tue Mar 29 04:54:37 EDT 2011

Dear Paul,

I really appreciated your proposed solution!
I'm using it!
After calling both of your functions I added the following source line

for m in p do close (m, false)


to prevent the modules to be left in open state. Without this addition, the previously opened modules remain in the DOORS memory as opened and they have prevented the further automatic run.
Now it works perfect, but it's very slow. I know, it is because of the hierarcy, looks like:
Top-Level <- System-Level <- High-Level <- Low-Level <- Test Cases
The arrows give the relationship between the levels.
It took for one system level module, which has links only to two high level modules, around 15 minutes to clean all the links. The module has only 231 object with inlinks.

Is there no quicker way to eliminate the modules? Such as power-delete or so something. Or delete folders regardless its content?

Thank you again for your help!

Best regards,
vasgyuszi

The code was created from fragments of DXL code that I copied out of other scripts that I have - I can see why it's taking so long. It's because the deleteIncomingLinks() function is saving the source module after each link deletion, it's also wasting time re loading the source modules which should have already been opened in the openSourceModules() function.

The best thing to do here is keep a record of all opened source module in a skip list and then go back and save those modules at the end. Have added this to the code, see below.
 

Object o
Module m = current
Module sourceModule
Skip skpModNames = createString() //will be used to keep track of which source modules were opened
string moduleNames 
string modFullName
Item i
 
 
bool openSourceModules(Object o) {
    ModName_ srcModRef
        string srcModFullName=""
        string srcModName=""
        Module modSrc=null
        bool allModsOpen = true
 
        // Open all modules that are the source of incoming links in edit mode
        for srcModRef in o<-"*" do {
                srcModFullName=fullName(srcModRef)
                srcModName=name(srcModRef)
                put(skpModNames, srcModFullName, srcModName)  //record details about each opened source module in the skip list
                modSrc=edit(srcModFullName, false)
                if (null modSrc) {  //provide a warning if a source cannot be opened in edit mode
                        infoBox "Cannot open for Edit module: " srcModFullName " \n\nThis script will halt execution."
                        allModsOpen = false
                        }
        }
        if (!allModsOpen) return false
        else return true
 
} //end of openSourceModules()
 
void deleteIncomingLinks(Object o) {
        Object objSrc
        Link l
 
        // Delete all incoming links
        for l in o<-"*" do {
                objSrc = source l
                delete l
                flushDeletions  
        }
} //End of deleteIncomingLinks()
 
 
//***************** MAIN ********************
 
for o in m do {
        if (!openSourceModules(o)) {
                delete skpModNames
                halt
                }
        }
 
for o in m do {
        deleteIncomingLinks(o)
        }
 
for moduleNames in skpModNames do {  //Use skip list to go back and save and close all opened source modules
        modFullName = (string key skpModNames)
        i = item(modFullName)
        sourceModule = module(i)
        save(sourceModule)
        close(sourceModule)
        }
 
delete skpModNames

 


Paul Miller
Melbourne, Australia

 

Re: deleting module without any question
vasgyuszi - Wed Mar 30 05:44:21 EDT 2011

SystemAdmin - Tue Mar 29 20:49:45 EDT 2011

The code was created from fragments of DXL code that I copied out of other scripts that I have - I can see why it's taking so long. It's because the deleteIncomingLinks() function is saving the source module after each link deletion, it's also wasting time re loading the source modules which should have already been opened in the openSourceModules() function.

The best thing to do here is keep a record of all opened source module in a skip list and then go back and save those modules at the end. Have added this to the code, see below.
 

Object o
Module m = current
Module sourceModule
Skip skpModNames = createString() //will be used to keep track of which source modules were opened
string moduleNames 
string modFullName
Item i
 
 
bool openSourceModules(Object o) {
    ModName_ srcModRef
        string srcModFullName=""
        string srcModName=""
        Module modSrc=null
        bool allModsOpen = true
 
        // Open all modules that are the source of incoming links in edit mode
        for srcModRef in o<-"*" do {
                srcModFullName=fullName(srcModRef)
                srcModName=name(srcModRef)
                put(skpModNames, srcModFullName, srcModName)  //record details about each opened source module in the skip list
                modSrc=edit(srcModFullName, false)
                if (null modSrc) {  //provide a warning if a source cannot be opened in edit mode
                        infoBox "Cannot open for Edit module: " srcModFullName " \n\nThis script will halt execution."
                        allModsOpen = false
                        }
        }
        if (!allModsOpen) return false
        else return true
 
} //end of openSourceModules()
 
void deleteIncomingLinks(Object o) {
        Object objSrc
        Link l
 
        // Delete all incoming links
        for l in o<-"*" do {
                objSrc = source l
                delete l
                flushDeletions  
        }
} //End of deleteIncomingLinks()
 
 
//***************** MAIN ********************
 
for o in m do {
        if (!openSourceModules(o)) {
                delete skpModNames
                halt
                }
        }
 
for o in m do {
        deleteIncomingLinks(o)
        }
 
for moduleNames in skpModNames do {  //Use skip list to go back and save and close all opened source modules
        modFullName = (string key skpModNames)
        i = item(modFullName)
        sourceModule = module(i)
        save(sourceModule)
        close(sourceModule)
        }
 
delete skpModNames

 


Paul Miller
Melbourne, Australia

 

Amazing!!! Thanks alot, dear Paul!

It works very well:
the complete processing time goes from 42 min. down to 6 min. for the whole linked project.

You gave me a direction to enhance the link deletion!
Indeed I've made it without the skip list, but I've added the save functionality to my little line, which looks now:

for m in p do {save m; close m}


instead of former

 

for m in p do close (m, false)


,and I've thinned out the deleteIncomingLinks exactly as you proposed newly.

Thank you again!

Best regards,
vasgyuszi